/**
 * 
 */
package dms.dto;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * @author 李健
 *
 */
public class RepairDTO extends ActionForm {

	private Long id;
	private Long dormitory;
	private String dormitoryName;
	private Long student;
	private String reason;
	private String title;
	private Date requestDate;
	private Long dormSupervisor;
	private Long building;
	private Boolean processed;
	private Boolean applied;
	private String fromDate;
	private String toDate;
	private String type;
	
	public Boolean getProcessed() {
		return processed;
	}
	public void setProcessed(Boolean processed) {
		this.processed = processed;
	}
	public Boolean getApplied() {
		return applied;
	}
	public void setApplied(Boolean applied) {
		this.applied = applied;
	}
	public String getFromDate() {
		return fromDate;
	}
	public void setFromDate(String fromDate) {
		this.fromDate = fromDate;
	}
	public String getToDate() {
		return toDate;
	}
	public void setToDate(String toDate) {
		this.toDate = toDate;
	}

	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	/**
	 * @return the dormitory
	 */
	public Long getDormitory() {
		return dormitory;
	}
	/**
	 * @param dormitory the dormitory to set
	 */
	public void setDormitory(Long dormitory) {
		this.dormitory = dormitory;
	}
	/**
	 * @return the student
	 */
	public Long getStudent() {
		return student;
	}
	/**
	 * @param student the student to set
	 */
	public void setStudent(Long student) {
		this.student = student;
	}
	/**
	 * @return the reason
	 */
	public String getReason() {
		return reason;
	}
	/**
	 * @param reason the reason to set
	 */
	public void setReason(String reason) {
		this.reason = reason;
	}
	/**
	 * @return the requestDate
	 */
	public Date getRequestDate() {
		return requestDate;
	}
	/**
	 * @param requestDate the requestDate to set
	 */
	public void setRequestDate(Date requestDate) {
		this.requestDate = requestDate;
	}
	/**
	 * @return the dormSupervisor
	 */
	public Long getDormSupervisor() {
		return dormSupervisor;
	}
	/**
	 * @param dormSupervisor the dormSupervisor to set
	 */
	public void setDormSupervisor(Long dormSupervisor) {
		this.dormSupervisor = dormSupervisor;
	}
	/**
	 * @return the building
	 */
	public Long getBuilding() {
		return building;
	}
	/**
	 * @param building the building to set
	 */
	public void setBuilding(Long building) {
		this.building = building;
	}
	
	public String getDormitoryName() {
		return dormitoryName;
	}
	public void setDormitoryName(String dormitoryName) {
		this.dormitoryName = dormitoryName;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.applied = null;
		this.building = null;
		this.dormitory = null;
		this.dormSupervisor = null;
		this.fromDate = null;
		this.id = null;
		this.processed = null;
		this.reason = null;
		this.requestDate = null;
		this.student = null;
		this.toDate = null;
		this.type = null;
		this.title = null;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		
		if (this.title == null || this.title.length() == 0) {
			errors.add("title", new ActionMessage("缺少标题", false));
		}
		if (this.reason == null || this.reason.length() == 0) {
			errors.add("reason", new ActionMessage("缺少原因", false));
		}
		if (!errors.isEmpty()) {
			String message = errors.toString();
			request.setAttribute("status", false);
			request.setAttribute("message", message);
		}
		return errors;
	}
}
